package com.share.device.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.common.core.utils.StringUtils;
import com.share.device.domain.CabinetType;
import com.share.device.mapper.CabinetTypeMapper;
import com.share.device.service.ICabinetTypeService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CabinetTypeServiceImpl extends ServiceImpl<CabinetTypeMapper, CabinetType> implements ICabinetTypeService {

    @Resource
    private CabinetTypeMapper cabinetTypeMapper;

    /**
     * 查询柜机类型列表
     *
     * @param cabinetType 柜机类型
     * @return 柜机类型
     */
    @Override
    public List<CabinetType> selectCabinetTypeList(CabinetType cabinetType) {
        LambdaQueryWrapper<CabinetType> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotEmpty(cabinetType.getName()), CabinetType::getName, cabinetType.getName());
        wrapper.eq(ObjectUtil.isNotEmpty(cabinetType.getStatus()), CabinetType::getStatus, cabinetType.getStatus());
        wrapper.like(StringUtils.isNotEmpty(cabinetType.getDescription()), CabinetType::getDescription, cabinetType.getDescription());
        wrapper.eq(StringUtils.isNotEmpty(cabinetType.getStatus()), CabinetType::getStatus, cabinetType.getStatus());
        wrapper.orderByDesc(CabinetType::getCreateTime);
        List<CabinetType> cabinetTypes = cabinetTypeMapper.selectList(wrapper);
        return cabinetTypes;
    }

}